package com.jxtech.hp.vdps.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.jxtech.hp.vdps.entity.Test;
import com.jxtech.hp.vdps.service.TestService;
import com.jxtech.hp.vdps.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author luojing
 * @create 2019/01/08 10:54 AM
 **/
@RestController
public class TestController {
  @Autowired
  private TestService testService;

  @RequestMapping("insert")
  public Result insert(){
    Test test = new Test();
    test.setTest("123");
    testService.insert(test);
    return Result.ok();
  }

  @RequestMapping("query")
  public Result query(){
    Page<Test> page = new Page(0,20);
    EntityWrapper<Test> entityWrapper = new EntityWrapper();
    entityWrapper.eq("test","123");
    testService.selectPage(page,entityWrapper);
    return Result.ok().putData(page.getRecords(),page.getTotal());
  }

  @RequestMapping("queryMy")
  public Result queryMy(){
    Page<Test> page = new Page(0,10);
    testService.queryPage(page,"123");
    return Result.ok().putData(page.getRecords(),page.getTotal());
  }

}
